@extends('layout.master')

@section('content-header')
    <h1>Kipem</h1>
    <ol class="breadcrumb">
        <li><a href="/"><i class="fa fa-dashboard"></i> Dashboard</a></li>
        <li><a href="{{ URL::route('kipems.index') }}"><i class="fa fa-file"></i> Kipem</a></li>
        <li class="active"><i class="fa fa-file"></i> Perpanjangan</li>
    </ol>
@stop

@section('content')
<style type="text/css">
    #box-filter li {
        margin-top: 15px;
    }
    #box-filter .collapse-toggle {
        margin-top: 30px;
    }
    #all-kipems-table th {
        vertical-align: middle;
    }
    #all-kipems-table th, td {
        font-size: 8pt;
    }
</style>
<div class="row">
    <div class="col-xs-12">

        <div class="box">
            <div class="box-body table-responsive">
                <div class="callout callout-warning">
                    <h4>Perpanjangan Kipem</h4>
                    <p>Pilih salah satu data Kipem untuk perpanjangan Kipem.</p>
                </div>
                <div class="row top10">
                    <div id="box-filter" class="col-md-12 no-padding">
                        <ul class="list-unstyled clearfix">
                            <li class="col-xs-4">
                                No. KTP
                                <input type="text" id="fl_no_ktp" class="form-control input-sm" placeholder="No. KTP"/>
                            </li>
                            <li class="col-xs-6">
                                Nama
                                <input type="text" id="fl_nama" class="form-control input-sm" placeholder="Nama"/>
                            </li>
                            <li class="col-xs-2">
                                <a href="#" class="btn btn-primary btn-cari" style="margin-top:18px; width:100%"><i class="fa fa-search"></i> Cari</a>
                            </li>
                        </ul>                   
                    </div>
                </div>
                    <hr>
                <table id="all-kipems-table" class="table table-bordered table-striped">
                    <thead>
                        <tr class="center">
                            <th>#</th>
                            <th>No. Kipem</th>
                            <th>No. KTP</th>
                            <th>Nama</th>
                            <th>Umur</th>
                            <th>Lokasi</th>
                            <th>Penduduk Penjamin</th>
                            <th>Tanggal Lapor</th>
                            <th>Berlaku Sampai</th>
                            <th width="10%">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div>
</div>
@stop

@section('javascript')
<script type="text/javascript">
    var fl_no_ktp = "";
    var fl_nama = "";

    $(function() {
        /**
         * All Penduduks Data table
         * 
         */
        allTable = $('#all-kipems-table').dataTable({
            "aoColumns": [
                { "bSearchable": true, "bSortable": true, "bVisible": false },
                { "sClass": "text-center", "bSearchable": true, "bSortable": false },
                { "sClass": "text-center", "bSearchable": true, "bSortable": false },
                { "bSearchable": true, "bSortable": false },
                { "sClass": "text-center", "bSearchable": true, "bSortable": false },
                { "bSearchable": true, "bSortable": false },
                { "bSearchable": true, "bSortable": false },
                { "sClass": "text-center", "bSearchable": true, "bSortable": false },
                { "sClass": "text-center", "bSearchable": true, "bSortable": false },
                { "sClass": "text-center", "bSearchable": false, "bSortable": false }
            ],
            "aLengthMenu": [[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, "All"]],
            "iDisplayLength": 50,
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "{{ URL::route('kipems.displayperpanjangan') }}",
            "bPaginate": true,
            "bSort": true,
            "bAutoWidth": false,
            "fnServerData": function( sSource, aoData, fnCallback ){                           
                aoData.push( 
                    { "name" : "fl_no_ktp", "value" : fl_no_ktp},
                    { "name" : "fl_nama", "value" : fl_nama}
                );                
                $.getJSON( sSource, aoData, function (json) {
                    fnCallback(json);                        
                    $('#all-kipems-table').find('.btn-tooltip').tooltip('hide');
                });
            }
        });

        /**
         * Filtering          
         */
        $('#box-filter').on('click', '.btn-cari', function(event) {
            event.preventDefault();
            fl_no_ktp = $('#fl_no_ktp').val();
            fl_nama = $('#fl_nama').val();
            allTable.fnReloadAjax();
        });

        /**
         * End of Filtering
         */
    });
</script>
@stop